﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web.Mvc;
using MvcApplication1.Utility;
using RIMS.Lib.Manager;
using RIMS.Lib.Models;

namespace MvcApplication1.Actions.EmployeeActions
{
    public class Search : Common, ISearch
    {
//        private readonly IEmployeeManager _employeeManager;
//        public Search(IEmployeeManager employeeManager)
//        {
//            _employeeManager = employeeManager;
//        }

        private const string NAME = "Name";
        private const string CODE = "Code";
        private const string MOBILE_NO = "MobileNo";
        private const string EMAIL = "Email";


        public Hashtable Execute(FormCollection collection)
        {


            Hashtable result = new Hashtable();
            try
            {
                InitSearch(collection);

                string query = Convert.ToString(collection[Tools.QTYPE]);

                switch (query)
                {
                    case NAME:
                        break;
                    case CODE:
                        break;
                    case MOBILE_NO:
                        break;
                    case EMAIL:
                        break;
                    default:
                        break;
                }

                IList<Employee> employees = new EmployeeManager().Paging(PAGE_NUMBER, RESULT_PER_PAGE);

                if (employees == null || employees.Count == 0)
                {
                    result[Tools.MESSAGE] = "Emplyee could not found";
                    return result;
                }

                FlexiGridObject gridObject = GetFlexiGridList(PAGE_NUMBER, 17, employees);
                result[Tools.PAGE] = gridObject.page;
                result[Tools.TOTAL] = gridObject.total;
                result[Tools.ROWS] = gridObject.rows;
                //esult[Tools.IS_ERROR] = false;
                return result;
            }
            catch (Exception ex)
            {

                return result;
            }
        }
    }
}